home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news!enno
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: Beginner: How to #include
- Date: 02 Feb 1996 19:33:16 GMT
- Organization: Fachbereich Informatik, TH Darmstadt
- Distribution: world
- Message-ID: <ENNO.96Feb2203316@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <west.32.008AC8C0@emt.e-technik.tu-muenchen.de>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: west@emt.e-technik.tu-muenchen.de's message of Tue, 30 Jan 1996 18:32:06 UNDEFINED
-
- In article <west.32.008AC8C0@emt.e-technik.tu-muenchen.de> west@emt.e-technik.tu-muenchen.de (Robert Westendorp) writes:
-
- Hi there,
-
- following problem with hierarchical including:
-
- my_data.h:
-
- #include "picture.h"
-
- class A
- {
- ..
- CPicture m_picture;
-
- ..
- }
-
- my_program.cpp:
- #INCLUDE "PICTURE.H"
- #include "my_data.h"
-
- program code...
-
- How can I avoid to include PICTURE.H in all of my files using
- class A from my_data.prg?
- There are lots of my_programm.cpp and a couple of my_data.h(s)!
-
- The preprocessor offers the a way to avoid multiple inclusion of header-files.
- For example the 'picture.h' file may look like:
-
- picture.h:
- #ifndef picture_h
- #define picture_h
- ...
- #endif
-
- When 'picture.h' is visited the first time the macro 'picture_h' is defined
- and the subsequent code '...' is included. The next time 'picture_h' is already
- defined and neither the macro is redefined nor the code is included.
- Take a look at your favorite system header-files. They are usually all wrapped
- in conditionals.
-
- Enno
-